<template>
  <div class="bar">
    <div class="title"></div>
    <div class="drag"></div>
    <div class="barOption">
      <div class="button minWin" @click="toMinSize">
        <div class="fontSet">-</div>
      </div>
      <div class="button maxWin" @click="toMaxSize">
        <div class="fontSet-child">□</div>
      </div>
      <div class="button closeWin" @click="closeWin">
        <div class="fontSet">×</div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { useRouter } from "vue-router";
import { computed } from "vue";
const { ipcRenderer } = require("electron");
const router = useRouter();
const currentRouterName = computed(() =>
  router.currentRoute.value.name === "login" ? true : false
);
const toMinSize = () => {
  currentRouterName.value
    ? ipcRenderer.send("toMinMainWin")
    : ipcRenderer.send("toMinSubWin");
};
const toMaxSize = () => {
  currentRouterName.value
    ? ipcRenderer.send("toMaxMainWin")
    : ipcRenderer.send("toMaxSubWin");
};
const closeWin = () => {
  currentRouterName.value
    ? ipcRenderer.send("closeMainWindow")
    : ipcRenderer.send("closeSubWin");
};
</script>
<style lang="scss" scoped>
.bar {
  //
  position: absolute;
  top: 0;
  height: 30px;
  width: 100%;
  background-color: #dcdfe6;
  box-sizing: border-box;
  box-shadow: 0px 2px 2px 0px inset #a6a9ad, 0px -2px 2px 0px inset #a6a9ad,
    0px 0px 2px 0px rgb(0 0 0 / 30%);
  display: flex;
  flex-direction: unset;
  .title {
    width: 100px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    color: #303133;
    // font-size: 14px;
  }
  .drag {
    height: 30px;
    -webkit-app-region: drag;
    flex: 1;
  }
  .barOption {
    width: 100px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    .button {
      width: 20px;
      height: 20px;
      border-radius: 20px;
      box-shadow: 0 0 2px 1px inset rgb(0 0 0 / 40%);
      cursor: pointer;
    }
    .minWin {
      background-color: #85ce61;
    }
    .maxWin {
      background-color: #ebb563;
    }
    .closeWin {
      background-color: #f78989;
    }
    .fontSet {
      width: 20px;
      height: 20px;
      line-height: 20px;
      font-weight: bold;
      color: #fff;
      opacity: 0;
      transition: 0.3s all ease-in;
    }
    .fontSet:hover {
      opacity: 1;
      transition: 0.3s all ease-in;
    }
    .fontSet-child {
      width: 20px;
      height: 20px;
      line-height: 16px;
      font-weight: bolder;
      color: #fff;
      opacity: 0;
      transition: 0.3s all ease-in;
    }
    .fontSet-child:hover {
      opacity: 1;
      transition: 0.3s all ease-in;
    }
  }
}
</style>
